import request from '@/utils/axios'

export type DataSourceConfigType = {
  id: number | undefined
  name: string
  url: string
  username: string
  password: string
  remark: string
}

export interface DataSourceConfigPageReqType extends PageParam {
  name?: string
}

/**
 * 数据源配置接口
 */
export const DataSourceConfigApi = {
  // 新增
  create: (data: DataSourceConfigType) => {
    return request.post({ url: '/infra/data-source-config/create', data, is_mock: true })
  },
  // 修改
  update: (data: DataSourceConfigType) => {
    return request.put({ url: '/infra/data-source-config/update', data, is_mock: true })
  },
  // 删除
  delete: (id: number) => {
    return request.delete({ url: '/infra/data-source-config/delete?id=' + id, is_mock: true })
  },
  // 查询详情
  detail: (id: number) => {
    return request.get({ url: '/infra/data-source-config/detail?id=' + id, is_mock: true })
  },
  // 查询分页列表
  page: (params: DataSourceConfigPageReqType) => {
    return request.get({ url: '/infra/data-source-config/page', params, is_mock: true })
  }
}
